#include "AssetManager.h"

CAssetManager::CAssetManager(void)
{
    FMOD_System_Create(&m_SoundSystem);
    FMOD_System_Init(m_SoundSystem, 10, FMOD_INIT_NORMAL, 0);
    mLogger = CLogger::GetInstance();
	mLogger->Init();
	mLogger->OutputErrorConsole("Asset Manager Initialized!");
}

CAssetManager::~CAssetManager(void)
{
    // TODO: Use batch to decide which set of sounds to load
    for (int i = 0; i < (int)mSoundList.size(); i++)
    {
        delete mSoundList[i];
    }
    FMOD_System_Release(m_SoundSystem);
}

void CAssetManager::RegisterAsset(CAsset* asset)
{
    CSound* snd = dynamic_cast<CSound*>(asset);
    if (snd)
    {
        snd->SetId(mSoundList.size());
        mSoundList.push_back(snd);
    }
    // TODO: Continue other asset checks here...
}

void CAssetManager::LoadAssets(int batch)
{
    // TODO: Use batch to decide which set of sounds to load
    for (int i = 0; i < (int)mSoundList.size(); i++)
    {
        mSoundList[i]->Create(m_SoundSystem);
    }

    // TODO: Loop through others lists and load them as well (animations, graphics, etc..)
}

